<?php

namespace App\BO\PaymentState\Pay;

use App\Entities\OrderModel;
use App\Entities\PaymentEntity;
use App\Utils\LjshMockTradeNoGeneratorUtil;
use Carbon\Carbon;

class PayFactory
{
    /**
     * @param PaymentEntity $paymentEntity
     * @return PayInfo
     */
    public static function getMockPayInfo(PaymentEntity $paymentEntity)
    {
        $payInfo = new PayInfo();
        $payInfo->setTradeNo($paymentEntity->getTradeNo());
        $payInfo->setPaySuccess(true);
        $payInfo->setPaidAt(Carbon::now());
        $payInfo->setPaymentMethod(OrderModel::PAYMENT_METHOD_LJSH);
        $payInfo->setPaymentNo(LjshMockTradeNoGeneratorUtil::getMockOutTradeNo());
        return $payInfo;
    }

    /**
     * wechat 通知
     * @param string $transactionId
     * @return PayInfo
     */
    public static function getPayInfoFromWechatNotify(string $transactionId)
    {
        $payInfo = new PayInfo();
        $payInfo->setPaySuccess(true);
        $payInfo->setPaidAt(Carbon::now());
        $payInfo->setPaymentMethod(OrderModel::PAYMENT_METHOD_WECHAT);
        $payInfo->setPaymentNo($transactionId);
        return $payInfo;
    }
}
